package com.sram.service;

import com.sram.controller.common.base.BaseMapper;
import com.sram.controller.common.base.BaseService;
import com.sram.dao.UserMapper;
import com.sram.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

/**
 * Created by Administrator on 2017/2/17.
 */
@Service("userService")
public class UserService extends BaseService<User,Integer> {
    @Resource
    private UserMapper userMapper;


    @Autowired
    public void setBaseMapper() {
        super.setBaseMapper(userMapper);
    }

    public List<User> getAll() throws Exception {
        List<User> ss = userMapper.getAll();
        return ss;
    }
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<User> getUserByName(String userName, String password) {
        List<User> ss = null;
//        for (int i = 0; i < 10000; i++) {
//            ss = userMapper.getAll();
//            System.out.println(ss.size());
////
//        }
       ss   = userMapper.getUserByName(userName, password);
        return ss;
    }
    @Transactional
    public void inserttest() {
        userMapper.insert(new User("dd", "dd"));
        userMapper.insert(new User("dd", "dd"));

    }
}
